package ai.zixing.example01;

/**
 * 测试类
 */
public class Client {
    public static void main(String[] args) {
        // 获取工厂对象
        FlyweightFactory factory = new FlyweightFactory();

        // 通过工厂对象获取共享的享元对象
        Flyweight a1 = factory.getFlyweight("A");
        a1.operation("a1ExState");
        Flyweight a2 = factory.getFlyweight("A");
        a2.operation("a2ExState");
        System.out.println(a1 == a2);

        // 获取非共享享元对象
        UnsharedConcreteFlyweight u1 = new UnsharedConcreteFlyweight("A");
        UnsharedConcreteFlyweight u2 = new UnsharedConcreteFlyweight("A");
        System.out.println(u1 == u2);
    }
}
